<%@ page language="java" import="java.util.*,com.zczx.gislab.model.Userinfo" pageEncoding="UTF-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Userinfo UInfo = (Userinfo)session.getAttribute("userinfo");
String photoUrl="";
if(UInfo==null){
    String username=session.getAttribute("username")==null?"":(String)session.getAttribute("username");
    String password=session.getAttribute("password")==null?"":(String)session.getAttribute("password");
    String nickname=session.getAttribute("nickname")==null?"":(String)session.getAttribute("nickname");
    String userid=session.getAttribute("userid")==null?"":(String)session.getAttribute("userid");
    UInfo = new Userinfo();
    UInfo.setId(userid);
    UInfo.setUsername(username);
    UInfo.setPassword(password);
    UInfo.setDefaultrole("student");
    UInfo.setNickname(nickname);
    UInfo.setName("");
    UInfo.setUniversity("");
    UInfo.setMajor("");
    UInfo.setPhoto("");
    UInfo.setSex(3);
    UInfo.setEnteryear(0);
    photoUrl="./imgs/useralt.png";
}else{
    photoUrl="./photos/"+UInfo.getPhoto();
}
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title data-localize="nav_userinfo"></title>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css">
    <link rel="stylesheet" href="style/page.css" >
    <link rel="stylesheet" href="style/myinfo.css">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <script type="text/javascript">
        var UserInfo={
            username:'<%=UInfo.getUsername()%>',
            password:'<%=UInfo.getPassword()%>',
            defaultrole:'<%=UInfo.getDefaultrole()%>',
            nickname:'<%=UInfo.getNickname()%>',
            name:'<%=UInfo.getName()%>',
            university:'<%=UInfo.getUniversity()%>',
            major:'<%=UInfo.getMajor()%>',
            photo:'<%=UInfo.getPhoto()%>',
            sex:'<%=UInfo.getSex()%>',
            enteryear:'<%=UInfo.getEnteryear()%>',
        };
        var UserID='<%=UInfo.getId()%>';
    </script>
</head>
<body>
    <%@ include file="head.jsp"%>
    <div id="container" class="container">
        <div class="infodiv">
            <div class="row myinfodiv">
                <div class="col-md-4">
                    <h4 data-localize="nav_userinfo"></h4>
                </div>
                <div class="col-md-8"></div>

            </div>
            <div>
                <ul class="nav nav-tabs" role="tablist">
                    <li role="presentation" class="active">
                        <a data-toggle="tab" href="#uname" data-localize="ms_usrinfo"></a>
                    </li>
                    <li role="presentation" style="display:none">
                        <a data-toggle="tab" href="#psw" data-localize="login_psw"></a>
                    </li>
                    <li role="presentation" style="display:none">
                        <a data-toggle="tab" href="#otherinf" data-localize="login_user"></a>
                    </li>
                </ul>
                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane active" id="uname">

                                   <div class="form-group userForm">
                                    <label for="loginName" class="control-label" data-localize="myinfo_userloginName"></label>
                                    <a style="display:none;" class="infolink" onclick="allowmdyLoginname()" data-localize="pm_modify"></a>

                                    <input type="text" class="form-control shortControl" id="loginName" disabled="disabled" data-localize="myinfo_userloginName" value="<%=UInfo.getUsername()%>">
                                </div>

                        <div class="form-group">
                            <label for="username" class="control-label" data-localize="pm_studentName"></label>
                            <span style="color:red;">*</span>
                            <input type="text" class="form-control shortControl" id="username" data-localize="pm_studentName" value="<%=UInfo.getName()%>">

                        </div>
                        <div class="form-group">
                            <label for="nickname" class="control-label" data-localize="ms_nickname"></label>
                            <span style="color:red;">*</span>
                            <input type="text" class="form-control shortControl" id="nickname" data-localize="ms_nickname" value="<%=UInfo.getNickname()%>">

                        </div>
                        <div class="form-group " id="userRoleGroup">
                            <label for="userDefaultRole" class="control-label" data-localize="ms_usrRole"></label>

                            <select type="text" class="form-control shortControl" id="userDefaultRole" >
                                <option value="teacher" data-localize="nav_teacher" <%=UInfo.getDefaultrole().equals("teacher")?"selected":""%> ></option>
                                <option value="student" data-localize="nav_student" <%=UInfo.getDefaultrole().equals("student")?"selected":""%> ></option>
                            </select>

                        </div>

                        <div class="form-group">
                            <label for="usrSchool" class="control-label" data-localize="pm_school"></label>
                            <span style="color:red;">*</span>
                            <input type="text" class="form-control shortControl" data-localize="pm_school" id="usrSchool" value="<%=UInfo.getUniversity()%>">

                        </div>
                        <div class="form-group ">
                            <label for="usrMajor" class="control-label" data-localize="ms_major"></label>
                            <span style="color:red;">*</span>
                            <input type="text" class="form-control shortControl" data-localize="ms_major" id="usrMajor" value="<%=UInfo.getMajor()%>">

                        </div>
                        <div class="form-group" >
                            <label for="classYear" class="control-label" data-localize="pm_classDes"></label>
                            <span style="color:red;">*</span>
                            <input type="text" class="form-control shortControl" data-localize="mi_enterYearTip" id="classYear" value="<%=UInfo.getEnteryear()==0?"":UInfo.getEnteryear()%>">

                        </div>
                           <div class="form-group" >
                            <label for="usrSex" class="control-label" data-localize="ms_sex"></label>

                            <select type="text" class="form-control shortControl" id="usrSex">
                                <option value="1" data-localize="ms_male" <%=UInfo.getSex()==1?"selected":""%>></option>
                                <option value="2" data-localize="ms_female" <%=UInfo.getSex()==2?"selected":""%>></option>
                                <option value="3" data-localize="ms_malefemale" <%=UInfo.getSex()==3?"selected":""%>></option>
                            </select>

                        </div>
                        <div class="form-group">
                            <label for="usrImgFile" class="control-label" data-localize="ms_headImg" style="display:block"></label>
                            <img id="usrImg" src='<%=photoUrl%>' data-localize="mi_defaultavatar"/>
                            <div class="btn btn-info fileuploadshell" onclick="javascript:document.getElementById('usrImgFile').click();">
                                <input type="file" class="form-control ifile" id="usrImgFile" name="usrImgFile" onchange="setPreImg()" accept="image/*">
                                <span class="glyphicon glyphicon-cloud-upload"></span>&nbsp;
                                <span class="filenamespan" data-localize="mi_avatarupload"></span>
                            </div>
                        </div>
                        <%=UInfo.getId()==""?"<div><input type=\"checkbox\" checked id=\"agreementCheck\"/>&nbsp;<span data-localize=\"mi_agreed\"></span>&nbsp;<a target=\"_blank\" href=\"./protocol.jsp\" data-localize=\"mi_gislabeduat\"></a></div>":""%>
                        <button data-localize="kc_btn_save" onclick="CreatOrModifyAct()" class="btn nextBtn"></button>
                    </div>
                    <div role="tabpanel" class="tab-pane" id="psw">
                        <div class="form-group userForm">
                            <label for="originPsw" class="control-label" data-localize="myinfo_originPsw"></label>

                            <input type="password" class="form-control shortControl" id="originPsw" data-localize="login_psw">

                        </div>
                        <div class="form-group ">
                            <label for="newPsw" class="control-label" data-localize="myinfo_newPsw"></label>

                            <input type="password" class="form-control shortControl" id="newPsw" data-localize="login_psw">
                            <p></p>
                            <label for="confirmPsw" class="control-label" data-localize="myinfo_repeatpsw"></label>

                            <input type="password" class="form-control shortControl" id="confirmPsw" data-localize="login_psw">
                        </div>
                        <button data-localize="pm_modify" onclick="changePsw()" class="btn nextBtn"></button>
                    </div>
                    <div role="tabpanel" class="tab-pane" id="otherinf">

                        <button data-localize="pm_modify" onclick="changeOtherInfo()" class="btn nextBtn"></button>


                    </div>

                </div>
            </div>


        </div>


        <div class="navbar-fixed-bottom cnter">
            <h6 data-localize="login_copyright"></h6>
        </div>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="http://cdn.bootcss.com/jquery/1.12.1/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <script src="script/jquery.i18n.properties.min.js"></script>
    <script src="script/jquery.i18n.init.js"></script>
    <script src="script/ajaxfileupload_zhang.js"></script>
    <script src="script/layerui/layer.js"></script>
    <script  src="script/myinfo.js"></script>
</body>
</html>